package com.webside.points.controller;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.webside.points.model.LikeEntity;
import com.webside.points.service.LikeService;

@Controller
@Scope("prototype")
@RequestMapping("/like/")
public class LikeController {
	
	@Autowired
	LikeService likeService;
	
	
	@RequestMapping("findById")
	public void findById(int answerId,int userId,HttpServletResponse response){
		
		LikeEntity likeEntity=new LikeEntity();
		likeEntity.setUserId(userId);
		likeEntity.setAnswerId(answerId);
		
		LikeEntity entity = likeService.findById(likeEntity);

		  String json = JSON.toJSONString(entity);
			try {
				response.getWriter().write(json);
				response.flushBuffer();
			} catch (Exception e) {
				System.out.println("JsonError："+e);
			}
		
	}

}
